package com.zwjstudy.cachestudy.redis7.lettuce.masterslave.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: JedisController
 * Package: com.zwjstudy.cachestudy.redis7.jedis.controller
 * Description:
 *
 * @Author: 张文俊
 * @Create: 2025-09-12 - 10:27
 * @Version: v1.0
 */
@RestController
public class JedisController {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    @GetMapping("/setv")
    public String setJedisValue(String key,String value){
        redisTemplate.opsForValue().set(key,value);

        return "成功";
    }

    @GetMapping("/getv")
    public Object getJedisValue(String key){

        return redisTemplate.opsForValue().get(key);
    }
    // 还可以操作 Hash, List, Set, ZSet 等
    // redisTemplate.opsForHash().put("myHash", "field", "value");
    // redisTemplate.opsForList().leftPush("myList", "value");
}
